{% extends "base.html" %}


{% block title %}{{ section.title }}{% endblock title %}


{% block header_logo %}
<p class="header-title">{{ config.title }} | {{ section.title }}</p>
{% endblock header_logo %}


{% block content %}
{{ section.content | safe }}

<div>
  <h2>Contents</h2>
  <ul>

    <!-- List parent -->
    {% if section.ancestors | length > 0 %}
    {% set parent = section.ancestors | last %}
    {% set parent_path = parent | as_str %}
    {% set parent_section = get_section(path=parent_path) %}
    <li>
      <a href="{{ parent_section.permalink }}">Back up</a>
    </li>
    {% else%}
    <li><a href=".">Back up</a></li>
    {% endif %}

    <!-- List pages -->
    {% set sorted_section_pages = section.pages | sort(attribute="title") %}
    {% for page in sorted_section_pages %}
    <li>
      <p>{% if page.date %}{{ page.date }} &bullet;{% endif %}
	<a href="{{ page.permalink }}">{{ page.title }}</a>
      </p>
      {% if page.description %}
      <p>{{ page.description }}</p>
      {% elif page.summary %}
      <p>{{ page.summary }}</p>
      {% else %}
      <p>{{ page.title }}....</p>
      {% endif %}
    </li>
    {% endfor %}

    <!-- List subsections -->
    {% set sorted_section_subsections = section.subsections | sort() %}
    {% for section_subsection in sorted_section_subsections %}
    {% set subsection = get_section(path=section_subsection) %}
    <li>
      <a href="{{ subsection.permalink | safe }}">{{ subsection.title }}</a>
    </li>
    {% endfor %}

  </ul>
</div>

{% endblock content %}
